package com.gitee.wsl.ext.json


import com.gitee.wsl.serialization.json.context.JsonContext.Default.decode
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement

fun <Value> JsonArray.toList(getValue: (JsonElement) -> Value): List<Value> = map(getValue)
inline fun <reified Value> JsonArray.toEnumList(): List<Value> = toContentList().decode()
fun JsonArray.toContentList(): List<String> = toList(JsonElement::toContent)
fun JsonArray.toIntList(): List<Int> = toList(JsonElement::toInt)
fun JsonArray.toLongList(): List<Long> = toList(JsonElement::toLong)
fun JsonArray.toFloatList(): List<Float> = toList(JsonElement::toFloat)
fun JsonArray.toDoubleList(): List<Double> = toList(JsonElement::toDouble)
fun JsonArray.toBooleanList(): List<Boolean> = toList(JsonElement::toBoolean)
